#!/bin/bash

# Set maintenance flag
MFLAG=/etc/columnstore/maintenance

exec {lock_fd}>/var/lock/mcs-restart || exit 1
flock -n "${lock_fd}" || { echo 'ERROR: This script is already running.' >&2; exit 1; }
touch "${MFLAG}"
mcs-stop
mcs-start
rm -f "${MFLAG}"
flock -u "${lock_fd}"
